package ui;

import java.util.List;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import each_class.RanKingClass;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;

public class MusicListView extends ScrolledView {

	public MusicListView(Composite parent, int style) {
		super(parent, style);
		RowLayout rowLayout = (RowLayout)getLayout();
		rowLayout.marginTop = 64;
		rowLayout.marginRight = 64;
		rowLayout.marginLeft = 32;
		rowLayout.wrap = true;
		rowLayout.type = SWT.HORIZONTAL;
		rowLayout.spacing = 40;
		setBounds(0, 0, 1210, 513);
		scrollHeight = 32;
	}

	
	public void loadMusicList(List<RanKingClass> list) {
		for (RanKingClass ranKingClass : list) {
			if (list != null) {
				new MusicListViewItem(this, ranKingClass);
				downcount += scrollHeight;
			}
		}
		layout();
	}
	
	@Override
	public void reachBottom() {
		if (!isWarned) {
			isWarned =! isWarned;
			downcount += scrollHeight;
			Label warnning = new Label(this, SWT.CENTER);
			warnning.setFont(new Font(getDisplay(), "Microsoft YaHei UI", 11, SWT.NORMAL));
			warnning.setSize(width, scrollHeight);
			warnning.setText("我是有底线的的！");
			layout();
		}
	}
}
